import { BrowserModule } from '@angular/platform-browser'
import { HashLocationStrategy, LocationStrategy } from '@angular/common'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import {
  HttpClientModule,
  HttpClientJsonpModule,
  HTTP_INTERCEPTORS
} from '@angular/common/http'
import { NgModule } from '@angular/core'
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'
import { AppRoutingModule } from './app-routing.module'
import { AppComponent } from './app.component'
import { CoreModule } from './@core/core.module'
import { SharedModule } from './@shared/shared.module'
import { Observable, of } from 'rxjs'
import { I18N } from '../config/language-config'
import { HomeComponent } from './home/home.component'
import { CollectionsComponent } from './collections/collections.component'
import { BlockchainComponent } from './blockchain/blockchain.component'
import { ModalComponent } from './home/modal/modal.component'
import { AvatarDetailComponent } from './collections/avatar-detail/avatar-detail.component'
import { AssetsDetailComponent } from './blockchain/assets-detail/assets-detail.component'
import { SelectAvatarTypeComponent } from './home/select-avatar-type/select-avatar-type.component'
import { LoginComponent } from './login/login.component'
import { RegisterComponent } from './login/register/register.component'
import { LoginsComponent } from './login/logins/logins.component'
import { ManageComponent } from './manage/manage.component'
import { CollectionComponent } from './manage/collection/collection.component'
import { CollectionDialogComponent } from './manage/collection/collection-dialog/collection-dialog.component'
import { ApiRequestInterceptor } from './api-request.interceptor'
import { MintComponent } from './manage/mint/mint.component'
import { UserManageComponent } from './manage/user-manage/user-manage.component'
import { DelectComponent } from './manage/user-manage/delect/delect.component'
import { BaseUserInfoComponent } from './base-user-info/base-user-info.component'
import { AccountComponent } from './base-user-info/account/account.component'
import { PasswordComponent } from './base-user-info/password/password.component'
import { StoreModule } from '@ngrx/store'
import { todoReducer } from './store/reducers/reducer'
import { avatarReducer } from './store/reducers/avatar.reducer'
import { UserVerificationComponent } from './user-verification/user-verification.component'
import { SpareComponent } from './@shared/components/spare/spare.component'
import { OperationConsoleComponent } from './manage/collection/operation-console/operation-console.component'
import { CountdownComponent } from './home/countdown/countdown.component'
import { FooterComponent } from './@shared/components/footer/footer.component'
import { HeaderComponent } from './@shared/components/header/header.component'
import { CollectionItemComponent } from './home/collection-item/collection-item.component'
import { MsgLoginComponent } from './login/msg-login/msg-login.component'
import { RegisterSuccessComponent } from './login/register-success/register-success.component'
import { OrderComponent } from './home/order/order.component'
import { QrCodeComponent } from './home/qr-code/qr-code.component'
import { QRCodeModule } from 'angular2-qrcode'
import { OrderManageComponent } from './order-manage/order-manage.component'
import { OrderListComponent } from './order-manage/order-list/order-list.component'
import { TransferComponent } from './collections/avatar-detail/transfer/transfer.component'
import { PhoneConnectComponent } from './base-user-info/phone-connect/phone-connect.component'
import { MarketComponent } from './market/market.component'
import { CookieService } from 'ngx-cookie-service'
class I18NLoader implements TranslateLoader {
  getTranslation(lang: 'zh-cn' | 'en-us'): Observable<Object> {
    return of(I18N[lang])
  }
}

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    CollectionsComponent,
    BlockchainComponent,
    ModalComponent,
    AvatarDetailComponent,
    AssetsDetailComponent,
    SelectAvatarTypeComponent,
    LoginComponent,
    RegisterComponent,
    LoginsComponent,
    ManageComponent,
    CollectionComponent,
    CollectionDialogComponent,
    MintComponent,
    UserManageComponent,
    BaseUserInfoComponent,
    AccountComponent,
    PasswordComponent,
    DelectComponent,
    UserVerificationComponent,
    SpareComponent,
    OperationConsoleComponent,
    CountdownComponent,
    FooterComponent,
    HeaderComponent,
    CollectionItemComponent,
    UserVerificationComponent,
    MsgLoginComponent,
    RegisterSuccessComponent,
    OrderComponent,
    QrCodeComponent,
    OrderManageComponent,
    OrderListComponent,
    TransferComponent,
    PhoneConnectComponent,
    MarketComponent
  ],
  imports: [
    QRCodeModule,
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    HttpClientJsonpModule,
    AppRoutingModule,
    CoreModule.forRoot(),
    SharedModule.forRoot(),
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useClass: I18NLoader
      }
    }),
    StoreModule.forRoot({ todos: todoReducer, avatar: avatarReducer })
  ],
  providers: [
    { provide: LocationStrategy, useClass: HashLocationStrategy },
    {
      provide: HTTP_INTERCEPTORS,
      useClass: ApiRequestInterceptor,
      multi: true
    },
    CookieService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
